Maths trick for fast calculation